<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>json字符串转换</title>
</head>
<body>

</body>
<script type="text/javascript">
    var jsonObj = {"stuName": "tom","stuAge":20};
    //将json对象或json数组转换为json字符串
    var jsonStr = JSON.stringify(jsonObj);
    //将json字符串转换为json对象或json数组
    var json = JSON.parse(jsonStr);
    console.log(jsonObj);
    console.log(jsonStr);
    console.log(json);
</script>
</html>